package com.wao.product.service.mapper;

import com.wao.product.domain.*;
import com.wao.product.service.dto.PictureDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Picture and its DTO PictureDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, })
public interface PictureMapper extends EntityMapper <PictureDTO, Picture> {

    @Mapping(source = "product.id", target = "productId")
    @Mapping(source = "product.name", target = "productName")
    PictureDTO toDto(Picture picture); 

    @Mapping(source = "productId", target = "product")
    Picture toEntity(PictureDTO pictureDTO); 
    default Picture fromId(Long id) {
        if (id == null) {
            return null;
        }
        Picture picture = new Picture();
        picture.setId(id);
        return picture;
    }
}
